Clover coverage report - Enterprise Web Services - 1.0
Coverage timestamp: Mon May 30 2005 17:10:32 CEST
file stats: LOC: 682   Methods: 14
NCLOC: 480   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
J2eeDeployWriter.java 62.9% 80.4% 92.9% 75.3%
coverage coverage
 1   
 /*
 2   
  * Copyright 2001-2004 The Apache Software Foundation.
 3   
  * 
 4   
  * Licensed under the Apache License, Version 2.0 (the "License");
 5   
  * you may not use this file except in compliance with the License.
 6   
  * You may obtain a copy of the License at
 7   
  * 
 8   
  *      http://www.apache.org/licenses/LICENSE-2.0
 9   
  * 
 10   
  * Unless required by applicable law or agreed to in writing, software
 11   
  * distributed under the License is distributed on an "AS IS" BASIS,
 12   
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13   
  * See the License for the specific language governing permissions and
 14   
  * limitations under the License.
 15   
  */
 16   
 package org.apache.geronimo.ews.ws4j2ee.toWs.ws;
 17   
 
 18   
 import org.apache.axis.Constants;
 19   
 import org.apache.axis.deployment.wsdd.WSDDConstants;
 20   
 import org.apache.axis.constants.Scope;
 21   
 import org.apache.axis.constants.Style;
 22   
 import org.apache.axis.constants.Use;
 23   
 import org.apache.axis.utils.JavaUtils;
 24   
 import org.apache.axis.utils.Messages;
 25   
 import org.apache.axis.wsdl.symbolTable.BindingEntry;
 26   
 import org.apache.axis.wsdl.symbolTable.CollectionTE;
 27   
 import org.apache.axis.wsdl.symbolTable.Element;
 28   
 import org.apache.axis.wsdl.symbolTable.FaultInfo;
 29   
 import org.apache.axis.wsdl.symbolTable.Parameter;
 30   
 import org.apache.axis.wsdl.symbolTable.Parameters;
 31   
 import org.apache.axis.wsdl.symbolTable.SchemaUtils;
 32   
 import org.apache.axis.wsdl.symbolTable.SymbolTable;
 33   
 import org.apache.axis.wsdl.symbolTable.TypeEntry;
 34   
 import org.apache.axis.wsdl.toJava.Emitter;
 35   
 import org.apache.axis.wsdl.toJava.JavaWriter;
 36   
 import org.apache.axis.wsdl.toJava.Utils;
 37   
 import org.apache.geronimo.ews.jaxrpcmapping.J2eeEmitter;
 38   
 import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
 39   
 import org.apache.geronimo.ews.ws4j2ee.context.j2eeDD.EJBContext;
 40   
 import org.apache.geronimo.ews.ws4j2ee.context.j2eeDD.WebContext;
 41   
 import org.apache.geronimo.ews.ws4j2ee.context.webservices.server.interfaces.WSCFHandler;
 42   
 import org.apache.geronimo.ews.ws4j2ee.context.webservices.server.interfaces.WSCFInitParam;
 43   
 import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationConstants;
 44   
 import org.apache.geronimo.ews.ws4j2ee.wsutils.EWSProvider;
 45   
 
 46   
 import javax.wsdl.Binding;
 47   
 import javax.wsdl.BindingOperation;
 48   
 import javax.wsdl.Definition;
 49   
 import javax.wsdl.Operation;
 50   
 import javax.wsdl.OperationType;
 51   
 import javax.wsdl.Port;
 52   
 import javax.wsdl.Service;
 53   
 import javax.wsdl.extensions.UnknownExtensibilityElement;
 54   
 import javax.wsdl.extensions.soap.SOAPBinding;
 55   
 import javax.xml.namespace.QName;
 56   
 import java.io.File;
 57   
 import java.io.FileOutputStream;
 58   
 import java.io.IOException;
 59   
 import java.io.OutputStreamWriter;
 60   
 import java.io.PrintWriter;
 61   
 import java.util.ArrayList;
 62   
 import java.util.Collection;
 63   
 import java.util.HashSet;
 64   
 import java.util.Iterator;
 65   
 import java.util.Map;
 66   
 import java.util.Vector;
 67   
 
 68   
 /**
 69   
  * This is Wsdl2java's deploy Writer.  It writes the deploy.wsdd file.
 70   
  */
 71   
 public class J2eeDeployWriter extends JavaWriter {
 72   
     protected boolean useProvider = false;
 73   
     /**
 74   
      * Field definition
 75   
      */
 76   
     protected Definition definition;
 77   
 
 78   
     /**
 79   
      * Field symbolTable
 80   
      */
 81   
     protected SymbolTable symbolTable;
 82   
     protected J2EEWebServiceContext wscontext;
 83   
 
 84   
     /**
 85   
      * Constructor.
 86   
      *
 87   
      * @param emitter
 88   
      * @param definition
 89   
      * @param symbolTable
 90   
      */
 91  15
     public J2eeDeployWriter(Emitter emitter, Definition definition,
 92   
                             SymbolTable symbolTable) {
 93  15
         super(emitter, "deploy");
 94  15
         this.definition = definition;
 95  15
         this.symbolTable = symbolTable;
 96  15
         wscontext = ((J2eeEmitter) emitter).getWscontext();
 97  15
         if (wscontext == null) {
 98  0
             throw new RuntimeException("wscontext can not be null");
 99   
         }
 100  15
         String val = System.getProperty("useProvider");
 101  15
         if(val != null){
 102  1
             useProvider = true;
 103   
         }
 104   
         
 105   
     }    // ctor
 106   
 
 107   
     /**
 108   
      * Generate deploy.wsdd.  Only generate it if the emitter
 109   
      * is generating server-side mappings.
 110   
      *
 111   
      * @throws IOException
 112   
      */
 113  15
     public void generate() throws IOException {
 114  15
         if (emitter.isServerSide()) {
 115  11
             super.generate();
 116   
         }
 117   
     }    // generate
 118   
 
 119   
     /**
 120   
      * Return the fully-qualified name of the deploy.wsdd file
 121   
      * to be generated.
 122   
      *
 123   
      * @return
 124   
      */
 125  11
     protected String getFileName() {
 126   
 //        String dir =
 127   
 //                emitter.getNamespaces().getAsDir(definition.getTargetNamespace());
 128  11
         String dir =
 129   
                 emitter.getNamespaces().getAsDir("");
 130  11
         return dir + "deploy.wsdd";
 131   
     }    // getFileName
 132   
 
 133   
     /**
 134   
      * Replace the default file header with the deployment doc file header.
 135   
      *
 136   
      * @param pw
 137   
      * @throws IOException
 138   
      */
 139  11
     protected void writeFileHeader(PrintWriter pw) throws IOException {
 140  11
         pw.println(Messages.getMessage("deploy00"));
 141  11
         pw.println(Messages.getMessage("deploy02"));
 142  11
         pw.println(Messages.getMessage("deploy03"));
 143  11
         pw.println(Messages.getMessage("deploy05"));
 144  11
         pw.println(Messages.getMessage("deploy06"));
 145  11
         pw.println(Messages.getMessage("deploy07"));
 146  11
         pw.println(Messages.getMessage("deploy09"));
 147  11
         pw.println();
 148  11
         pw.println("<deployment");
 149  11
         pw.println("    xmlns=\"" + WSDDConstants.URI_WSDD + "\"");
 150  11
         pw.println("    xmlns:" + WSDDConstants.NS_PREFIX_WSDD_JAVA + "=\""
 151   
                 + WSDDConstants.URI_WSDD_JAVA + "\">");
 152   
     }    // writeFileHeader
 153   
 
 154   
     /**
 155   
      * Write the body of the deploy.wsdd file.
 156   
      *
 157   
      * @param pw
 158   
      * @throws IOException
 159   
      */
 160  11
     protected void writeFileBody(PrintWriter pw) throws IOException {
 161  11
         writeDeployServices(pw);
 162  11
         pw.println("</deployment>");
 163   
     }    // writeFileBody
 164   
 
 165   
     /**
 166   
      * Write out deployment and undeployment instructions for each WSDL service
 167   
      *
 168   
      * @param pw
 169   
      * @throws IOException
 170   
      */
 171  11
     protected void writeDeployServices(PrintWriter pw) throws IOException {
 172   
         // deploy the ports on each service
 173  11
         Map serviceMap = definition.getServices();
 174  11
         for (Iterator mapIterator = serviceMap.values().iterator();
 175  22
              mapIterator.hasNext();) {
 176  11
             Service myService = (Service) mapIterator.next();
 177  11
             pw.println();
 178  11
             pw.println("  <!-- "
 179   
                     + Messages.getMessage("wsdlService00", myService.getQName().getLocalPart()) + " -->");
 180  11
             pw.println();
 181  11
             for (Iterator portIterator = myService.getPorts().values().iterator();
 182  22
                  portIterator.hasNext();) {
 183  11
                 Port myPort = (Port) portIterator.next();
 184  11
                 BindingEntry bEntry =
 185   
                         symbolTable.getBindingEntry(myPort.getBinding().getQName());
 186   
 
 187   
                 // If this isn't an SOAP binding, skip it
 188  11
                 if (bEntry.getBindingType() != BindingEntry.TYPE_SOAP) {
 189  0
                     continue;
 190   
                 }
 191  11
                 writeDeployPort(pw, myPort, myService, bEntry);
 192   
             }
 193   
         }
 194   
     }    // writeDeployServices
 195   
 
 196   
     /**
 197   
      * Write out bean mappings for each type
 198   
      *
 199   
      * @param pw
 200   
      * @param binding
 201   
      * @param hasLiteral
 202   
      * @param hasMIME
 203   
      * @param use
 204   
      * @throws IOException
 205   
      */
 206  11
     protected void writeDeployTypes(PrintWriter pw, Binding binding, boolean hasLiteral, boolean hasMIME, Use use)
 207   
             throws IOException {
 208  11
         pw.println();
 209  11
         if (hasMIME) {
 210  0
             QName bQName = binding.getQName();
 211  0
             writeTypeMapping(pw, bQName.getNamespaceURI(), "DataHandler",
 212   
                     "javax.activation.DataHandler",
 213   
                     "org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory",
 214   
                     "org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory",
 215   
                     use.getEncoding());
 216   
         }
 217  11
         Map types = symbolTable.getTypeIndex();
 218  11
         Collection typeCollection = types.values();
 219  11
         for (Iterator i = typeCollection.iterator(); i.hasNext();) {
 220  64
             TypeEntry type = (TypeEntry) i.next();
 221   
 
 222   
             // Note this same check is repeated in JavaStubWriter.
 223  64
             boolean process = true;
 224   
 
 225   
             // 1) Don't register types that are base (primitive) types.
 226   
             // If the baseType != null && getRefType() != null this
 227   
             // is a simpleType that must be registered.
 228   
             // 2) Don't register the special types for collections
 229   
             // (indexed properties) or element types
 230   
             // 3) Don't register types that are not referenced
 231   
             // or only referenced in a literal context.
 232  64
             if (((type.getBaseType() != null) && (type.getRefType() == null))
 233   
                     || (type instanceof CollectionTE)
 234   
                     || (type instanceof Element) || !type.isReferenced()
 235   
                     || type.isOnlyLiteralReferenced()) {
 236  39
                 process = false;
 237   
             }
 238  64
             if (process) {
 239  25
                 String namespaceURI = type.getQName().getNamespaceURI();
 240  25
                 String localPart = type.getQName().getLocalPart();
 241  25
                 String javaType = type.getName();
 242  25
                 String serializerFactory;
 243  25
                 String deserializerFactory;
 244  25
                 String encodingStyle = "";
 245  25
                 if (!hasLiteral) {
 246  25
                     encodingStyle = use.getEncoding();
 247   
                 }
 248  25
                 if (javaType.endsWith("[]")) {
 249  18
                     if (SchemaUtils.isListWithItemType(type.getNode())) {
 250  0
                         serializerFactory =
 251   
                                 "org.apache.axis.encoding.ser.SimpleListSerializerFactory";
 252  0
                         deserializerFactory =
 253   
                                 "org.apache.axis.encoding.ser.SimpleListDeserializerFactory";
 254   
                     } else {
 255  18
                         serializerFactory =
 256   
                                 "org.apache.axis.encoding.ser.ArraySerializerFactory";
 257  18
                         deserializerFactory =
 258   
                                 "org.apache.axis.encoding.ser.ArrayDeserializerFactory";
 259   
                     }
 260  7
                 } else if ((type.getNode() != null) && (Utils.getEnumerationBaseAndValues(type.getNode(), symbolTable) != null)) {
 261  0
                     serializerFactory =
 262   
                             "org.apache.axis.encoding.ser.EnumSerializerFactory";
 263  0
                     deserializerFactory =
 264   
                             "org.apache.axis.encoding.ser.EnumDeserializerFactory";
 265  7
                 } else if (type.isSimpleType()) {
 266  0
                     serializerFactory =
 267   
                             "org.apache.axis.encoding.ser.SimpleSerializerFactory";
 268  0
                     deserializerFactory =
 269   
                             "org.apache.axis.encoding.ser.SimpleDeserializerFactory";
 270  7
                 } else if (type.getBaseType() != null) {
 271  0
                     serializerFactory =
 272   
                             "org.apache.axis.encoding.ser.SimpleSerializerFactory";
 273  0
                     deserializerFactory =
 274   
                             "org.apache.axis.encoding.ser.SimpleDeserializerFactory";
 275   
                 } else {
 276  7
                     serializerFactory =
 277   
                             "org.apache.axis.encoding.ser.BeanSerializerFactory";
 278  7
                     deserializerFactory =
 279   
                             "org.apache.axis.encoding.ser.BeanDeserializerFactory";
 280   
                 }
 281  25
                 writeTypeMapping(pw, namespaceURI, localPart, javaType,
 282   
                         serializerFactory, deserializerFactory,
 283   
                         encodingStyle);
 284   
             }
 285   
         }
 286   
     }    // writeDeployTypes
 287   
 
 288   
     /**
 289   
      * Raw routine that writes out the typeMapping.
 290   
      *
 291   
      * @param pw
 292   
      * @param namespaceURI
 293   
      * @param localPart
 294   
      * @param javaType
 295   
      * @param serializerFactory
 296   
      * @param deserializerFactory
 297   
      * @param encodingStyle
 298   
      * @throws IOException
 299   
      */
 300  25
     protected void writeTypeMapping(PrintWriter pw, String namespaceURI, String localPart, String javaType, String serializerFactory, String deserializerFactory, String encodingStyle)
 301   
             throws IOException {
 302  25
         pw.println("      <typeMapping");
 303  25
         pw.println("        xmlns:ns=\"" + namespaceURI + "\"");
 304  25
         pw.println("        qname=\"ns:" + localPart + '"');
 305  25
         pw.println("        type=\"java:" + javaType + '"');
 306  25
         pw.println("        serializer=\"" + serializerFactory + "\"");
 307  25
         pw.println("        deserializer=\"" + deserializerFactory + "\"");
 308  25
         pw.println("        encodingStyle=\"" + encodingStyle + "\"");
 309  25
         pw.println("      />");
 310   
     }
 311   
 
 312   
     /**
 313   
      * Write out deployment and undeployment instructions for given WSDL port
 314   
      *
 315   
      * @param pw
 316   
      * @param port
 317   
      * @param service
 318   
      * @param bEntry
 319   
      * @throws IOException
 320   
      */
 321  11
     protected void writeDeployPort(PrintWriter pw, Port port, Service service, BindingEntry bEntry)
 322   
             throws IOException {
 323  11
         String serviceName = port.getName();
 324  11
         boolean hasLiteral = bEntry.hasLiteral();
 325  11
         boolean hasMIME = Utils.hasMIME(bEntry);
 326  11
         String prefix = WSDDConstants.NS_PREFIX_WSDD_JAVA;
 327  11
         String styleStr = "";
 328  11
         Use use = Use.DEFAULT;
 329  11
         Iterator iterator =
 330   
                 bEntry.getBinding().getExtensibilityElements().iterator();
 331   
 
 332   
         //get the Name of the provider needed in the deploy.wsdd
 333  11
         String provider = null;
 334  11
         provider = GenerationConstants.WS4J2EE_PROVIDER;
 335  11
         while (iterator.hasNext()) {
 336  11
             Object obj = iterator.next();
 337  11
             if (obj instanceof SOAPBinding) {
 338  11
                 use = Use.ENCODED;
 339  0
             } else if (obj instanceof UnknownExtensibilityElement) {
 340   
                 // TODO: After WSDL4J supports soap12, change this code
 341  0
                 UnknownExtensibilityElement unkElement =
 342   
                         (UnknownExtensibilityElement) obj;
 343  0
                 QName name =
 344   
                         unkElement.getElementType();
 345  0
                 if (name.getNamespaceURI().equals(Constants.URI_WSDL12_SOAP)
 346   
                         && name.getLocalPart().equals("binding")) {
 347  0
                     use = Use.ENCODED;
 348   
                 }
 349   
             }
 350   
         }
 351  11
         if (symbolTable.isWrapped()) {
 352  0
             styleStr = " style=\"" + Style.WRAPPED + "\"";
 353  0
             use = Use.LITERAL;
 354   
         } else {
 355  11
             styleStr = " style=\"" + bEntry.getBindingStyle().getName() + "\"";
 356  11
             if (hasLiteral) {
 357  0
                 use = Use.LITERAL;
 358   
             }
 359   
         }
 360  11
         String useStr = " use=\"" + use + "\"";
 361   
 //        if(provider!= null){
 362   
 //            pw.println("  <service name=\"" + serviceName + "\" provider=\""
 363   
 //                    + provider + "\"" + styleStr + useStr + ">");
 364   
 //            WSCFHandler[] handlers = wscontext.getMiscInfo().getHandlers();    
 365   
 //            for(int i = 0;i<handlers.length;i++){
 366   
 //                writeHandler(pw,handlers[i]);
 367   
 //            }    
 368   
 //        }else{
 369   
 //            pw.println("  <service name=\"" + serviceName + "\" provider=\""
 370   
 //                    + prefix + ":RPC" + "\"" + styleStr + useStr + ">");
 371   
 //        }
 372  11
         if (this.useProvider) {
 373  1
             String continer = wscontext.getMiscInfo().getTargetJ2EEContainer();
 374  1
             if (GenerationConstants.GERONIMO_CONTAINER.equals(continer)) {
 375   
 //                pw.println("    <service name=\"" + serviceName + "\" provider=\"java:geronimo\""
 376   
 //                        + styleStr + useStr + ">");
 377  0
                 pw.println("    <service name=\"" + serviceName + "\" provider=\"Handler\""
 378   
                         + styleStr + useStr + ">");
 379  0
                 pw.println("      <parameter name=\"handlerClass\" value=\"org.apache.geronimo.axis.GeronimoProvider\"/>");
 380   
             } else {
 381   
 //                pw.println("  <service name=\"" + serviceName + "\" provider=\"java:ews\""
 382   
 //                        + styleStr + useStr + ">");
 383  1
                 pw.println("    <service name=\"" + serviceName + "\" provider=\"Handler\"" 
 384   
                       + styleStr + useStr + ">");
 385  1
                 pw.println("      <parameter name=\"handlerClass\" value=\"org.apache.geronimo.ews.ws4j2ee.wsutils.EWSProvider\"/>");
 386   
               //pw.println("        <java:provider  java:className=\"org.apache.geronimo.ews.ws4j2ee.wsutils.EWSProvider\" java:isStatic=\"true\"/>\n");
 387   
                         //
 388   
                         //java:className
 389   
             }
 390   
         } else {
 391  10
             pw.println("  <service name=\"" + serviceName + "\" provider=\"java:j2ee\""
 392   
                     + styleStr + useStr + ">");
 393   
         }
 394  11
         EJBContext ejbcontext = wscontext.getEJBDDContext();
 395  11
         if (ejbcontext != null) {
 396  8
             pw.println("      <parameter name=\""+EWSProvider.OPTION_USE_EJB+"\" value=\"ejb\"/>");
 397  8
             if (ejbcontext.getEjbhomeInterface() != null) {
 398  8
                 pw.println("      <parameter name=\""+EWSProvider.OPTION_HOMEINTERFACE_NAME+"\" value=\""
 399   
                         + ejbcontext.getEjbhomeInterface() + "\"/>");
 400   
             }
 401  8
             if (ejbcontext.getEjbRemoteInterface() != null) {
 402  8
                 pw.println("      <parameter name=\""+EWSProvider.OPTION_REMOTEINTERFACE_NAME+"\" value=\""
 403   
                         + ejbcontext.getEjbRemoteInterface() + "\"/>");
 404   
             }
 405  8
             if (ejbcontext.getEjbLocalHomeInterfce() != null) {
 406  0
                 pw.println("      <parameter name=\""+EWSProvider.OPTION_LOCALHOMEINTERFACE_NAME+"\" value=\""
 407   
                         + ejbcontext.getEjbLocalHomeInterfce() + "\"/>");
 408   
             }
 409  8
             if (ejbcontext.getEjbLocalInterface() != null) {
 410  0
                 pw.println("      <parameter name=\""+EWSProvider.OPTION_LOCALINTERFACE_NAME+"\" value=\""
 411   
                         + ejbcontext.getEjbLocalInterface() + "\"/>");
 412   
             }
 413  8
             if (ejbcontext.getEjbRemoteInterface() != null) {
 414  8
                 pw.println("      <parameter name=\""+EWSProvider.OPTION_HOMEINTERFACE_NAME+"\" value=\""
 415   
                         + "ejb/" + ejbcontext.getEjbName() + "\"/>");
 416   
             }
 417  8
             if (ejbcontext.getEjbRemoteInterface() != null) {
 418  8
                 pw.println("      <parameter name=\""+EWSProvider.OPTION_EJB_NAME+"\" value=\""
 419   
                         + ejbcontext.getEjbName() + "\"/>");
 420   
             }
 421   
         }else{
 422  3
             pw.println("      <parameter name=\""+EWSProvider.OPTION_USE_EJB+"\" value=\"web\"/>");
 423   
         }
 424  11
         pw.println("      <parameter name=\"wsdlTargetNamespace\" value=\""
 425   
                 + service.getQName().getNamespaceURI() + "\"/>");
 426  11
         pw.println("      <parameter name=\"wsdlServiceElement\" value=\""
 427   
                 + service.getQName().getLocalPart() + "\"/>");
 428  11
         pw.println("      <parameter name=\"wsdlServicePort\" value=\""
 429   
                 + serviceName + "\"/>");
 430   
 
 431   
         // MIME attachments don't work with multiref, so turn it off.
 432  11
         if (hasMIME) {
 433  0
             pw.println("      <parameter name=\"sendMultiRefs\" value=\"false\"/>");
 434   
         }
 435  11
         writeDeployBinding(pw, bEntry);
 436  11
         writeDeployTypes(pw, bEntry.getBinding(), hasLiteral, hasMIME, use);
 437  11
         WSCFHandler[] handlers = this.wscontext.getMiscInfo().getHandlers();
 438  11
         if (handlers != null) {
 439  11
             for (int i = 0; i < handlers.length; i++) {
 440  2
                 writeHandler(pw, handlers[i]);
 441   
             }
 442   
         }
 443  11
         pw.println("  </service>");
 444   
     }    // writeDeployPort
 445   
 
 446   
     /**
 447   
      * Write out deployment instructions for given WSDL binding
 448   
      *
 449   
      * @param pw
 450   
      * @param bEntry
 451   
      * @throws IOException
 452   
      */
 453  11
     protected void writeDeployBinding(PrintWriter pw, BindingEntry bEntry)
 454   
             throws IOException {
 455  11
         Binding binding = bEntry.getBinding();
 456  11
         String className = bEntry.getName();
 457  11
         if (emitter.isSkeletonWanted()) {
 458  0
             className += "Skeleton";
 459   
         } else {
 460  11
             className += "Impl";
 461   
         }
 462  11
         if (this.useProvider) {
 463  1
             WebContext webContext = wscontext.getWebDDContext();
 464  1
             if (webContext != null) {
 465  1
                 pw.println("      <parameter name=\"className\" value=\"" + webContext.getServletClass()
 466   
                         + "\"/>");
 467   
             }
 468   
         } else {
 469  10
             pw.println("      <parameter name=\"className\" value=\"" + className
 470   
                     + "\"/>");
 471   
         }
 472  11
         pw.println("      <parameter name=\"wsdlPortType\" value=\""
 473   
                 + binding.getPortType().getQName().getLocalPart() + "\"/>");
 474  11
         HashSet allowedMethods = new HashSet();
 475  11
         if (!emitter.isSkeletonWanted()) {
 476  11
             Iterator operationsIterator =
 477   
                     binding.getBindingOperations().iterator();
 478  11
             for (; operationsIterator.hasNext();) {
 479  40
                 BindingOperation bindingOper =
 480   
                         (BindingOperation) operationsIterator.next();
 481  40
                 Operation operation = bindingOper.getOperation();
 482  40
                 OperationType type = operation.getStyle();
 483  40
                 String javaOperName =
 484   
                         JavaUtils.xmlNameToJava(operation.getName());
 485   
 
 486   
                 // These operation types are not supported.  The signature
 487   
                 // will be a string stating that fact.
 488  40
                 if ((type == OperationType.NOTIFICATION)
 489   
                         || (type == OperationType.SOLICIT_RESPONSE)) {
 490  0
                     continue;
 491   
                 }
 492  40
                 allowedMethods.add(javaOperName);
 493   
 
 494   
                 // We pass "" as the namespace argument because we're just
 495   
                 // interested in the return type for now.
 496  40
                 Parameters params =
 497   
                         symbolTable.getOperationParameters(operation, "", bEntry);
 498  40
                 if (params != null) {
 499   
                     // Get the operation QName
 500  40
                     QName elementQName = Utils.getOperationQName(bindingOper,
 501   
                             bEntry, symbolTable);
 502   
 
 503   
                     // Get the operation's return QName and type
 504  40
                     QName returnQName = null;
 505  40
                     QName returnType = null;
 506  40
                     if (params.returnParam != null) {
 507  35
                         returnQName = params.returnParam.getQName();
 508  35
                         returnType = Utils.getXSIType(params.returnParam);
 509   
                     }
 510   
 
 511   
                     // Get the operations faults
 512  40
                     Map faultMap = bEntry.getFaults();
 513  40
                     ArrayList faults = null;
 514  40
                     if (faultMap != null) {
 515  40
                         faults = (ArrayList) faultMap.get(bindingOper);
 516   
                     }
 517   
 
 518   
                     // Write the operation metadata
 519  40
                     writeOperation(pw, javaOperName, elementQName, returnQName,
 520   
                             returnType, params, binding.getQName(),
 521   
                             faults);
 522   
                 }
 523   
             }
 524   
         }
 525  11
         pw.print("      <parameter name=\"allowedMethods\" value=\"");
 526  11
         if (allowedMethods.isEmpty()) {
 527  0
             pw.println("*\"/>");
 528   
         } else {
 529  11
             boolean first = true;
 530  11
             for (Iterator i = allowedMethods.iterator(); i.hasNext();) {
 531  40
                 String method = (String) i.next();
 532  40
                 if (first) {
 533  11
                     pw.print(method);
 534  11
                     first = false;
 535   
                 } else {
 536  29
                     pw.print(" " + method);
 537   
                 }
 538   
             }
 539  11
             pw.println("\"/>");
 540   
         }
 541  11
         Scope scope = emitter.getScope();
 542  11
         if (scope != null) {
 543  0
             pw.println("      <parameter name=\"scope\" value=\""
 544   
                     + scope.getName() + "\"/>");
 545   
         }
 546   
     }    // writeDeployBinding
 547   
 
 548   
     /**
 549   
      * Raw routine that writes out the operation and parameters.
 550   
      *
 551   
      * @param pw
 552   
      * @param javaOperName
 553   
      * @param elementQName
 554   
      * @param returnQName
 555   
      * @param returnType
 556   
      * @param params
 557   
      * @param bindingQName
 558   
      * @param faults
 559   
      */
 560  40
     protected void writeOperation(PrintWriter pw, String javaOperName,
 561   
                                   QName elementQName, QName returnQName,
 562   
                                   QName returnType, Parameters params,
 563   
                                   QName bindingQName, ArrayList faults) {
 564  40
         pw.print("      <operation name=\"" + javaOperName + "\"");
 565  40
         if (elementQName != null) {
 566  40
             pw.print(" qname=\""
 567   
                     + Utils.genQNameAttributeString(elementQName, "operNS")
 568   
                     + "\"");
 569   
         }
 570  40
         if (returnQName != null) {
 571  35
             pw.print(" returnQName=\""
 572   
                     + Utils.genQNameAttributeStringWithLastLocalPart(returnQName, "retNS")
 573   
                     + "\"");
 574   
         }
 575  40
         if (returnType != null) {
 576  35
             pw.print(" returnType=\""
 577   
                     + Utils.genQNameAttributeString(returnType, "rtns")
 578   
                     + "\"");
 579   
         }
 580  40
         if ((params.returnParam != null) && params.returnParam.isOutHeader()) {
 581  0
             pw.print(" returnHeader=\"true\"");
 582   
         }
 583  40
         pw.println(" >");
 584  40
         Vector paramList = params.list;
 585  40
         for (int i = 0; i < paramList.size(); i++) {
 586  54
             Parameter param = (Parameter) paramList.elementAt(i);
 587   
 
 588   
             // Get the parameter name QName and type QName
 589  54
             QName paramQName = param.getQName();
 590  54
             QName paramType = Utils.getXSIType(param);
 591  54
             pw.print("        <parameter");
 592  54
             if ((paramQName == null)
 593   
                     || "".equals(paramQName.getNamespaceURI())) {
 594  54
                 pw.print(" name=\"" + param.getName() + "\"");
 595   
             } else {
 596  0
                 pw.print(" qname=\""
 597   
                         + Utils.genQNameAttributeStringWithLastLocalPart(paramQName, "pns")
 598   
                         + "\"");
 599   
             }
 600  54
             pw.print(" type=\""
 601   
                     + Utils.genQNameAttributeString(paramType, "tns") + "\"");
 602   
 
 603   
             // Get the parameter mode
 604  54
             if (param.getMode() != Parameter.IN) {
 605  0
                 pw.print(" mode=\"" + getModeString(param.getMode()) + "\"");
 606   
             }
 607   
 
 608   
             // Is this a header?
 609  54
             if (param.isInHeader()) {
 610  0
                 pw.print(" inHeader=\"true\"");
 611   
             }
 612  54
             if (param.isOutHeader()) {
 613  0
                 pw.print(" outHeader=\"true\"");
 614   
             }
 615  54
             pw.println("/>");
 616   
         }
 617  40
         if (faults != null) {
 618  40
             for (Iterator iterator = faults.iterator(); iterator.hasNext();) {
 619  0
                 FaultInfo faultInfo = (FaultInfo) iterator.next();
 620  0
                 QName faultQName = faultInfo.getQName();
 621  0
                 if (faultQName != null) {
 622  0
                     String className =
 623   
                             Utils.getFullExceptionName(faultInfo.getMessage(),
 624   
                                     symbolTable);
 625  0
                     pw.print("        <fault");
 626  0
                     pw.print(" name=\"" + faultInfo.getName() + "\"");
 627  0
                     pw.print(" qname=\""
 628   
                             + Utils.genQNameAttributeString(faultQName, "fns")
 629   
                             + "\"");
 630  0
                     pw.print(" class=\"" + className + "\"");
 631  0
                     pw.print(" type=\""
 632   
                             + Utils.genQNameAttributeString(faultInfo.getXMLType(), "tns") + "\"");
 633  0
                     pw.println("/>");
 634   
                 }
 635   
             }
 636   
         }
 637  40
         pw.println("      </operation>");
 638   
     }
 639   
 
 640   
     /**
 641   
      * Method getModeString
 642   
      *
 643   
      * @param mode
 644   
      * @return
 645   
      */
 646  0
     public String getModeString(byte mode) {
 647  0
         if (mode == Parameter.IN) {
 648  0
             return "IN";
 649  0
         } else if (mode == Parameter.INOUT) {
 650  0
             return "INOUT";
 651   
         } else {
 652  0
             return "OUT";
 653   
         }
 654   
     }
 655   
 
 656   
     /**
 657   
      * Method getPrintWriter
 658   
      *
 659   
      * @param filename
 660   
      * @return
 661   
      * @throws IOException
 662   
      */
 663  11
     protected PrintWriter getPrintWriter(String filename) throws IOException {
 664  11
         File file = new File(filename);
 665  11
         File parent = new File(file.getParent());
 666  11
         parent.mkdirs();
 667  11
         FileOutputStream out = new FileOutputStream(file);
 668  11
         OutputStreamWriter writer = new OutputStreamWriter(out, "UTF-8");
 669  11
         return new PrintWriter(writer);
 670   
     }
 671   
 
 672  2
     private void writeHandler(PrintWriter pw, WSCFHandler handler) {
 673  2
         pw.println("      <handler name=\"" + handler.getHandlerName() + "\"type=\"" + handler.getHandlerClass() + "\">");
 674  2
         WSCFInitParam[] param = handler.getInitParam();
 675  2
         for (int i = 0; i < param.length; i++) {
 676  1
             pw.println("      <parameter name=\"" + param[i].getParamName() + "\" value=\"" + param[i].getParamValue() + "\"/>");
 677   
         }
 678   
         //TODO handle soap role and soaphandlers 
 679  2
         pw.println("      </handler>");
 680   
     }
 681   
 }    // class JavaDeployWriter
 682